function* generator(){
  for (let index = 0; index < 4; index++) {
    yield index
  }
}

const g = generator()
console.log(g.next())
console.log(g.next())
console.log(g.next())
console.log(g.next())
console.log(g.next())